package com.piggy.common.core.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum CacheKeyEnums {
    RegUserSms("regUserSms", "用户短信注册", CacheKeyEnums.sysPrefix, 10L),
    SysDept("sysDept", "部门", CacheKeyEnums.sysPrefix),
    SysClient("sysClientDetails", "终端配置表", CacheKeyEnums.sysPrefix,-1L),
    SysUser("sysUser", "用户表", CacheKeyEnums.sysPrefix),
    SysUserName("sysUserName", "用户表", CacheKeyEnums.sysPrefix),
    SysUserPhone("sysUserPhone", "用户表", CacheKeyEnums.sysPrefix),
    SysUserEmail("sysUserEmail", "用户表", CacheKeyEnums.sysPrefix),
    SysConfig("sysConfig", "系统配置表", CacheKeyEnums.sysPrefix, -1L),
    SysDict("sysDict", "数据字典表", CacheKeyEnums.sysPrefix, -1L),
    SysDictType("sysDictType", "数据字典类型表", CacheKeyEnums.sysPrefix, -1L),
    //LogiSysDict("logiSysDict", "物流服务商数据字典表", CacheKeyEnums.sysPrefix, -1L),
    //LogiSysDictType("logiSysDictType", "物流服务商数据字典类型表", CacheKeyEnums.sysPrefix, -1L),
    LogiDept("logiDept", "部门", CacheKeyEnums.logiPrefix),
    LogiUser("logiUser", "用户表", CacheKeyEnums.logiPrefix),
    LogiUserName("logiUserName", "用户表", CacheKeyEnums.logiPrefix),
    LogiUserPhone("logiUserPhone", "用户表", CacheKeyEnums.sysPrefix),
    LogiUserEmail("logiUserEmail", "用户表", CacheKeyEnums.sysPrefix),
    LogiGeoBranch("logiGeoBranch", "部门网点GEO", CacheKeyEnums.logiPrefix),
    LogiGeoLineBranch("logiGeoLineBranch", "线路部门网点GEO", CacheKeyEnums.logiPrefix),
    LogiScheduleNo("logiScheduleNo", "调度单号NO", CacheKeyEnums.logiPrefix),
    LogiDrayageNo("logiDrayageNo", "短驳单号NO", CacheKeyEnums.logiPrefix),
    LogiBusNo("logiBusNo", "调度单车次NO", CacheKeyEnums.logiPrefix),
    LogiIssueNo("logiIssueNo", "问题单号NO", CacheKeyEnums.logiPrefix),
    LogiFineNo("logiFineNo", "罚款单号NO", CacheKeyEnums.logiPrefix),
    LogiGoodOrderNo("logiGoodOrderNo", "商品订单NO", CacheKeyEnums.logiPrefix),

    ;

    CacheKeyEnums(String code, String desc, String prefix) {
        this.code = code;
        this.desc = desc;
        this.prefix = prefix;
        this.time = TimeOut;
    }

    /** key **/
    private final String code;
    /** 描述 **/
    private final String desc;
    /**
     * 前缀
     */
    private final String prefix;
    private final Long time;

    private final static String sysPrefix = "sys";
    private final static String logiPrefix = "logi";
    private final static long TimeOut = 30L;

    public String getKey(Object...keys) {
        StringBuilder redisKey = new StringBuilder(this.prefix);
        redisKey.append(":").append(this.code);
        for(Object key : keys) {
            if (ObjectUtil.isNotNull(key)) {
                redisKey.append(":").append(key);
            }
        }
        return redisKey.toString();
    }

}
